/**
 * 选择排序
 * @param {*} arr
 */
function selected(arr) {
  let temp = null
  for (let i = 0, len = arr.length; i < len; i++) {
    let minIndex = i
    for (let j = i, len = arr.length; j < len; j++) {
      if (arr[minIndex] > arr[j]) minIndex = j
    }
    if (minIndex !== i) {
      temp = arr[i]
      arr[i] = arr[minIndex]
      arr[minIndex] = temp
      temp = null
    }
  }
  return arr
}
console.log(selected([1, 2, 5, 7, 8, 0, 9]))
